From 04c049ee54027ce5a1149125ef579ec48a853df0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 26 Mar 2023 20:51:27 +0200 Subject: [PATCH] listitem: Add a backwards compatibility workaround I want to avoid turning the :focusable property into a tristate at all costs, but that third state is what we had before the property. --- gtk/gtklistitem.c | 8 ++++++++ gtk/gtklistitemprivate.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c index 7aed3f410d..59f450f97b 100644 --- a/gtk/gtklistitem.c +++ b/gtk/gtklistitem.c @@ -337,6 +337,12 @@ gtk_list_item_set_child (GtkListItem *self, { g_object_ref_sink (child); self->child = child; + + /* Workaround that hopefully achieves good enough backwards + * compatibility with people using expanders. + */ + if (!self->focusable_set) + gtk_list_item_set_focusable (self, !gtk_widget_get_focusable (child)); } if (self->owner) @@ -533,6 +539,8 @@ gtk_list_item_set_focusable (GtkListItem *self, { g_return_if_fail (GTK_IS_LIST_ITEM (self)); + self->focusable_set = TRUE; + if (self->focusable == focusable) return; diff --git a/gtk/gtklistitemprivate.h b/gtk/gtklistitemprivate.h index 28ab8b5d63..99adbeee4c 100644 --- a/gtk/gtklistitemprivate.h +++ b/gtk/gtklistitemprivate.h @@ -22,6 +22,7 @@ #include "gtklistitem.h" #include "gtklistitemwidgetprivate.h" +#include "gtkversion.h" G_BEGIN_DECLS @@ -36,6 +37,9 @@ struct _GtkListItem guint activatable : 1; guint selectable : 1; guint focusable : 1; +#if !GTK_CHECK_VERSION (5, 0, 0) + guint focusable_set : 1; +#endif }; GtkListItem * gtk_list_item_new (void); -- 2.30.2